<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
Yii::setPathOfAlias('uploadPath', dirname(__FILE__) . '/../../files/sweeUpload');
require(dirname(__FILE__) . '/../helpers/handy_funcs.php');
$config = array(
//    'onBeginRequest' => create_function('$event', 'return ob_start("ob_gzhandler");'),
//    'onEndRequest'   => create_function('$event', 'return ob_end_flush();'),
    'theme'          => 'frontend',
    'name'           => 'Frontend-DK',
    'language'       => 'en',
    'sourceLanguage' => 'en',
    'preload'        => array('log'),
    'import'         => array(
        'application.models.*',
        'application.models.user.*',
        'application.models.clock.*',
        'application.models.page.*',
        'application.components.*',
        'application.components.notification.*',
        'application.extensions.crontab.*',
        'ext.sweekit.Sweeml',
        'ext.EDataTables.*',
    ),
//    'defaultController' => 'frontend/site',
    'modules'        => array(
        'webmaster',
        'gii' => array(
            'class'    => 'system.gii.GiiModule',
            'password' => 'dung 10110606',
        ),
    ),
    'components'     => array(
        'messages'     => array(
            'class' => 'CPhpMessageSource',
        ),
        'fixture'      => array(
            'class' => 'system.test.CDbFixtureManager',
        ),
        'clientScript' => array(
            'behaviors' => array(
                'sweelixClientScript' => array(
                    'class' => 'ext.sweekit.behaviors.SwClientScriptBehavior',
                ),
            ),
        ),
        'errorHandler' => array(
            'errorAction' => 'webmaster/site/error',
        ),
        'errorHandler' => array(
            'errorAction' => 'site/error'
        ),
        'user'         => array(
            // enable cookie-based authentication
            'allowAutoLogin' => true,
            'class'          => 'WebUser',
            'loginUrl'       => array('site/login'),
        ),
        'urlManager'   => array(
            'class'          => 'application.components.UrlManager',
            'urlFormat'      => 'path',
            'showScriptName' => false,
            'rules'          => array(
                'gii'                                                                => 'gii',
                'webmaster'                                                          => 'webmaster/site/admin',
                '<language:(lang)>/'                                                 => 'site/index',
                '<language:(lang)>/contact'                                          => 'site/contact',
                'contact'                                                            => 'site/contact',
                'faq'                                                                => 'page/faq',
                '<language:(lang)>/faq'                                              => 'page/faq',
                '<language:(lang)>/<url:(about-us|privacy-policy|terms-conditions)>' => 'page/index',
                '<url:(about-us|privacy-policy|terms-conditions)>'                   => 'page/index',
                '<language:(lang)>/webmaster/<controller:\w+>'                       => 'webmaster/<controller>',
                'webmaster/<controller:\w+>'                                         => 'webmaster/<controller>',
                '<language:(lang)>/webmaster/<controller:\w+>/<action:\w+>'          => 'webmaster/<controller>/<action>',
                'webmaster/<controller:\w+>/<action:\w+>'                            => 'webmaster/<controller>/<action>',
                '<language:(lang)>/<controller:\w+>/<id:\d+>'                        => '<controller>/view',
                '<language:(lang)>/<controller:\w+>/<action:\w+>/<id:\d+>'           => '<controller>/<action>',
                '<controller:\w+>/<id:\d+>'                                          => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'                             => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>'                                      => '<controller>/<action>',
            ),
        ),
        'log'          => array(
            'class'  => 'CLogRouter',
            'routes' => array(
                array(
                    'class'      => 'CFileLogRoute',
                    'levels'     => 'trace,log',
                    'categories' => 'system.db.CDbCommand',
                    'logFile'    => 'db.log',
                ),
            )
        ),
        'authManager'  => array(
            'class'           => 'CDbAuthManager',
            'connectionID'    => 'db',
            'itemChildTable'  => 'tbl_auth_item_child',
            'itemTable'       => 'tbl_auth_item',
            'assignmentTable' => 'tbl_auth_assignment',
        ),
        'db'           => require(dirname(__FILE__) . '/db.php'),
        'phpThumb'     => array(
            'class' => 'ext.EPhpThumb.EPhpThumb',
        ),
        'bitly'        => require 'bitly.php',
    ),
    'params'         => require 'params.php',
);
return $config;
